import { createWebHistory, createRouter } from 'vue-router'

import HomeView from '../views/home/index.vue'
import Login from '../views/login.vue'
import Detail from '../views/detail.vue'
import Goods from '../views/goods.vue'

import Home from '../views/home/home.vue'
import Sort from '../views/home/sort.vue'
import Cart from '../views/home/cart.vue'
import My from '../views/home/my.vue'
import Card from '../views/home/card.vue'

const routes = [
  { path: '/', redirect: '/home' },
  {
    path: '/home',
    component: HomeView,
    children: [
      {
        path: '/home',
        component: Home,
      },
      {
        path: '/sort',
        component: Sort,
      },
      {
        path: '/cart',
        component: Cart,
      },
      {
        path: '/my',
        component: My,
      },
      {
        path: '/card',
        component: Card,
      },
    ]
  },
  {
    path: '/login',
    component: Login,
  },
  {
    path: '/detail',
    component: Detail,
  },
  {
    path: '/goods',
    component: Goods,
  },
]

export const router = createRouter({
  history: createWebHistory(),
  routes,
})